const app = getApp();
var config = app.globalData.config;
const http = require('../../utils/http.js');
Page({
	data: {
		userInfo: [],
		student_list: []
	},
	onReady: function(options) {
		if (!app.login()) {
			return;
		}
		this.userInfo = app.globalData.userInfo;
		if (this.userInfo.avatar == null) {
			this.userInfo.avatar = "/image/headimg.png";
		}
		if (this.userInfo.username == null || this.userInfo.username == "") {
			this.userInfo.username = "普通用户";
		}
		if (this.userInfo.nickname == null || this.userInfo.nickname == "") {
			this.userInfo.nickname = "小优";
		}
		this.setData({
			"userInfo": app.globalData.userInfo
		});
	},
	onLoad(options) {
		//初始化用户信息
		this.getStudentList(); //初始化孩子列表
	},
	goInformation() {
		let userInfo = JSON.stringify(this.data.userInfo)
		wx.navigateTo({
			url: './Personal_information?userinfo=' + userInfo,
		})
	},
	godetails(e) {
		let studentid = e.currentTarget.dataset.id
		console.log(e);
		console.log(studentid);
		let student = JSON.stringify(this.data.student_list)
		wx.navigateTo({
			url: '../order_list/details?student=' + student + '&studentid=' + studentid,
		})
	},
	getStudentList() {
		var that = this;
		http.httpPost(config.get_student_list, {}, function(e) {
			that.student_list = e.data;
			that.setData({
				'student_list': e.data
			});
		});
	},
	developmentFun() {
		wx.showToast({
			title: "开发中",
			icon: 'none',
			duration: 1000,
			mask: true
		});
	}


})
